< previous page page_887 next page >

Page 887
Several things are happening in Listing A.14. Let's review the routine more closely. After setting up the error trap and initializing variables, the main While..Wend loop starts. This loop reads a line from the script file opened by SQLFileOpen, updates a line counter, removes any trailing or leading spaces from the line, and then adds a single space at the end of the line. This single space is added to help the GetToken function do its work.
The SQL-VB5 program processes each line of script word by word. The first word in each command line is used to determine how SQL-VB5 processes the line. The GetToken function returns the first word in the line (you learn more about GetToken a bit later). Next, you show the current script line to the user by updating SQLVBMain.lblProgress. Notice that you added the DoEvents command right after updating the label. This forces your program to pause a moment, and that allows Windows time to send the message that ultimately updates the SQLVBMain form.
Once the main form is updated, the program must handle the word it pulled from the script line. Usually, the word is an SQL keyword and SQL-VB5 can add it to the cSQLLine variable for eventual processing. However, there are several words that require special handling. These words are listed in Table A.6 along with comments about how they are handled.
Table A.6. Script words that require special handling.
Script WordHandling Comments
//This is the comment word. If a line begins with this keyword, ignore the rest of the line and get the next line in the script. You must leave at least one space between the // and the comment. For example, //comment would be rejected by SQL-VB5, but // comment is just fine.
DBCONNECTThis is the keyword that you can use to set the CONNECT property of the database. This allows you to open non-Microsoft Jet databases or even ODBC data sources. Consult the Microsoft Visual Basic documentation for valid syntax here. Basically, anything that works in Visual Basic's Connect property works here, too.
DBVERSIONThis is the value that sets the version of database to be created. Valid values are 1.1, 2.0, and 3.0.
DBOPENThis is the OpenDatabase word. If a line starts with this keyword, call a special routine (SQLdbOpen) that executes a Visual Basic OpenDatabase operation.

continues

 
< previous page page_887 next page >

If you like this book, buy it!